#include "myserver.h"
#include "mainwindow.h"
MyServer::MyServer(QObject *parent):QTcpServer(parent)
{

}


MyServer::~MyServer()
{
    //析构时清空sock描述符链表
    //sockDescList.clear();
    userList.clear();
}

void MyServer::incomingConnection(qintptr sockDesc)
{
    qDebug()<<"incomingConnection!"<<endl;
    Mythread *thread=new Mythread (sockDesc);
    //将套接字描述符存到套接字链表中
//    sockDescList.append(sockDesc);
//    for(int i=0;i<sockDescList.length();i++)
//    {
//        qDebug()<<"sockDescList:"<<sockDescList[i]<<" ";
//    }
//    qDebug()<<endl;

    thread->start();
    connect(thread,SIGNAL(finished()),thread,SLOT(deleteLater()));
    connect(thread,SIGNAL(dataReady(char *)),this,SIGNAL(dataReady(char *)));

}


